package custom.security.validator;

import lombok.extern.slf4j.Slf4j;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @MyNotBlank注解的校验规则
 * Created by security on 2017/9/23.
 */
@Slf4j
public class MyNotBlankValidator implements ConstraintValidator<MyNotBlank, String> {
    @Override
    public void initialize(MyNotBlank myNotBlank) {
        log.info("my not blank initialize success");
    }


    @Override
    public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {
        log.info("");
        log.info("valid str:{}",s);
        boolean b =  s == null ? false:s.trim().length()> 0 ? true:false;
        log.info("b.result :{}",b);
        log.info("");
        return b;
    }
}
